{extend name="layout/iframe" /}

{block name="content"}
<div class="x-body">
    <form action="" method="post" class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
                <span class="x-red">*</span>角色名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="name" name="name" value="{$info.name}" required="" lay-verify="name" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">
                拥有权限
            </label>
            <table class="layui-table layui-input-block">
                <tbody>
                <tr>
                    <!--<td>
                        <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>权限管理</span><i class="layui-icon"></i></div>
                    </td>-->
                    <td>
                        <div class="layui-input-block">
                            {foreach name="rules" item="rule" key="key"}
                            <input name="ruleIds[]" lay-skin="primary" type="checkbox" title="{$rule.name}" value="{$rule.id}" {if condition="(in_array($rule['id'], $info['access']))"}checked="checked"{/if} >
                            <div class="layui-unselect layui-form-checkbox" lay-skin="primary">
                                <span>{$rule.name}</span><i class="layui-icon"></i>
                            </div>
                            {/foreach}
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="layui-form-item layui-form-text">
            <label for="desc" class="layui-form-label">
                描述
            </label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" id="desc" name="remark" class="layui-textarea">{$info.remark}</textarea>
            </div>
        </div>

        <input type="hidden" name="id" value="{$info.id}" >
        <div class="layui-form-item">
            <button class="layui-btn" lay-submit="" lay-filter="add">保存</button>
        </div>
    </form>
</div>

<script>
    var save_url = "{:url('admin/role/savePost')}";
</script>
<script src="__STATIC__/admin/pages/js/role.js" type="text/javascript"></script>
{/block}